package com.codinghero.core.dao;

import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.codinghero.core.bo.NameValBo;
import com.codinghero.core.dto.NameVal;
import com.codinghero.zqlb.spider.dao.BaseDao;

public class NameValDao extends BaseDao {
	
	protected static Logger log = Logger.getLogger(NameValBo.class);
	
	public NameVal getNameValByName(String name) throws SQLException {
		return dbOper.selectOne("SELECT * FROM core_name_val WHERE name='" + name + "'", NameVal.class);
	}
	
	public int insertNameVal(NameVal nameVal) throws SQLException {
		return dbOper.insertOne(nameVal);
	}
	
	public int insertNameVal(String name, String val) throws SQLException {
		NameVal nameVal = new NameVal();
		nameVal.setName(name);
		nameVal.setVal(val);
		return dbOper.insertOne(nameVal);
	}
	
	public int updateNameVal(String name, String val) throws SQLException {
		return dbOper.executeUpdate("UPDATE core_name_val SET val='" + val + "' WHERE name='" + name + "'");
	}
}
